<?php
//echo $_POST['username'];
//echo '</br>';
//echo $_REQUEST['sex'];
//echo '</br>';
//echo $_REQUEST['message'];
//echo '</br>';
//echo '<img src='.'"'.$_REQUEST['imgurl'].'"'.'/>';
$name=$_REQUEST['username'];
$sex=$_REQUEST['sex'];
$msg=$_REQUEST['message'];
$img=$_REQUEST['imgurl'];
date_default_timezone_set("Asia/Shanghai");
$date=date('Y-m-d H:i:s');
//将性别、头像、当前留言
require 'dbcon.php';//连接数据库
$sql="insert into t_message(username,sex,message,imgurl,m_date) values('{$name}','{$sex}','{$msg}','{$img}','{$date}')";
$rs=$db->query($sql);//执行SQL语句
//exit;  程序到此处终止
if($rs==true)//根据返回结果，做不同的响应
    {
    // echo "留言成功";
    //Header("Location:index.php");//直接跳转
    echo"<script language='javascript' type='text/javascript'>";
    echo "alert('留言成功！');";
    echo"window.location.href='index.php';";
    echo"</script>";
    exit;
    //JavaScript弹出对话框跳转
}else{
    echo"<script language='javascript'>";
    echo"alert('留言失败！');";
    echo"window.location.href='index.php';";
    echo"</script>";//JavaScript弹出对话框跳转
    exit;
}